//
//  TestVRViewController.swift
//  YiZhangGui
//
//  Created by 卢逢卫 on 2025/1/21.
//

import UIKit
import AVFoundation
import Vision

class TestVRViewController: BaseController {
    
//    var captureSession: AVCaptureSession!
//       var previewLayer: AVCaptureVideoPreviewLayer!
//       
//       override func viewDidLoad() {
//           super.viewDidLoad()
//           setupCamera()
//       }
//       
//       func setupCamera() {
//           captureSession = AVCaptureSession()
//           guard let videoCaptureDevice = AVCaptureDevice.default(for: .video) else { return }
//           let videoInput: AVCaptureDeviceInput
//           
//           do {
//               videoInput = try AVCaptureDeviceInput(device: videoCaptureDevice)
//           } catch {
//               return
//           }
//           
//           if (captureSession.canAddInput(videoInput)) {
//               captureSession.addInput(videoInput)
//           } else {
//               return
//           }
//           
//           previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
//           previewLayer.frame = view.layer.bounds
//           previewLayer.videoGravity = .resizeAspectFill
//           view.layer.addSublayer(previewLayer)
//           
//           captureSession.startRunning()
//           
//           let output = AVCaptureVideoDataOutput()
//           output.setSampleBufferDelegate(self, queue: DispatchQueue(label: "videoQueue"))
//           captureSession.addOutput(output)
//       }
//   }
//
//   extension TestVRViewController: AVCaptureVideoDataOutputSampleBufferDelegate {
//       func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
//           guard let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { return }
//           
//           let request = VNRecognizeHandGestureRequest { (request, error) in
//               // 处理识别结果
//               if let results = request.results as? [VNRecognizedObjectObservation] {
//                   for result in results {
//                       // 在这里处理识别到的手势
//                       print("Detected gesture: \(result)")
//                   }
//               }
//           }
//           
//           do {
//               try VNImageRequestHandler(cvPixelBuffer: pixelBuffer, options: [:]).perform([request])
//           } catch {
//               print(error)
//           }
//       }
}
